package com.biz;

import com.dao.BookImgMapper;
import com.dao.BooksMapper;
import com.entity.BookImg;
import com.entity.Books;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class IBookBizImp implements IBookBiz{

    @Autowired
    private BooksMapper booksDao;
    @Autowired
    private BookImgMapper imgDao;

    public BooksMapper getBooksDao() {
        return booksDao;
    }

    public void setBooksDao(BooksMapper booksDao) {
        this.booksDao = booksDao;
    }

    @Override
    public PageInfo getAll(Books books,Integer pageNum) {
        PageHelper.startPage(pageNum,10);
        PageInfo pageInfo=new PageInfo(booksDao.getAll(books)) ;
        return pageInfo;
    }

    @Override
    public void addBook(Books books) {
        booksDao.addBook(books);
    }

    @Override
    public void modBook(Books books) {
        booksDao.modBook(books);
    }

    @Override
    public void delBook(int bid) {
        booksDao.delBook(bid);
    }

    @Override
    public Books getById(int bid) {
        return booksDao.getById(bid);
    }

    @Override
    public Integer addBookImg(BookImg bookImg) {
        return imgDao.insertSelective(bookImg);
    }

    @Override
    public Integer getNewBook() {
        return booksDao.getNewBook();
    }

    @Override
    public Books getByBookId(Integer bookid) {
        return booksDao.getByBookId(bookid);
    }
}
